<?php 
/*
# ------------------------------------------------------------------------
# JA Job Board Package
# ------------------------------------------------------------------------
# Copyright (C) 2004-2010 JoomlArt.com. All Rights Reserved.
# @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
# Author: JoomlArt.com
# Websites: http://www.joomlart.com - http://www.joomlancers.com.
# ------------------------------------------------------------------------
*/
defined('_JEXEC') or die('Restricted access'); 
?>
<script language="javascript" type="text/javascript">

function submitbutton(pressbutton) {
	var form = document.adminForm;

	if (pressbutton == 'cancel') {
		submitform( pressbutton );
		return;
	}
	if ( pressbutton == 'savestruct' || pressbutton == 'apply' ){
		if(selected == '' ){
		    alert('<?php echo JText::_('PLEASE SELECT A LOOP ELEMENT')?>');
			return;
		}
		
		submitform( pressbutton );
	}					
	else {
		submitform( pressbutton );
	}
}

function confirmLink(theLink, theConfirmMsg)
   {
       // Check if Confirmation is not needed
       // or browser is Opera (crappy js implementation)
       if (theConfirmMsg == '' || typeof(window.opera) != 'undefined') {
           return true;
       }

       var is_confirmed = confirm(theConfirmMsg + '\n');
       if (is_confirmed) {
           theLink.href += '&is_js_confirmed=1';
       }

       return is_confirmed;
   } // end of the 'confirmLink()' function

function checkBoxes(checkbox, name) {
	
	var form, state, boxes, count,i;
	form = checkbox.form;
	state = checkbox.checked;
	
	boxes = document.getElementsByName(""+name);

	count = boxes.length; 
	for (i=0;i<count;i++)
		boxes[i].checked = state;

}
var selected = "";
function selectSeqElement (name) {
	selected = name;
	
	if (selectSeqElement.previousName) {
		document.getElementById(selectSeqElement.previousName).style.background='#ffffff';document.getElementById(selectSeqElement.previousName+'_end').style.background='#ffffff';
	}
	document.getElementById(name).style.background='#FFFF00';document.getElementById(name+'_end').style.background='#FFFF00';

	start_x = findPosX(document.getElementById(name+''));
	start_y = findPosY(document.getElementById(name+''));
	end_x = findPosX(document.getElementById(name+'_end'));
	end_y = findPosY(document.getElementById(name+'_end'));
	var v_line = document.getElementById('v_line');
	v_line.style.display='inline';
	
	if(navigator.userAgent.indexOf("MSIE") > 0)
		v_line.style.left = start_x-23;
	
	if(navigator.userAgent.indexOf("MSIE") > 0)
		v_line.style.margin = (start_y-320)+"px auto auto "+"10px";
	else
		v_line.style.margin = (start_y-320)+"px auto auto "+(start_x-280)+"px";
	
	v_line.style.height = end_y-start_y+"px";
	selectSeqElement.previousName=name;
	
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

//Taken from http://www.quirksmode.org/js/findpos.html; but modified
function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

</script>
<form action="index.php" method="post" name="adminForm" enctype="multipart/form-data" id="adminForm">

<div class="col100">
	<?php 
	
	echo $this->menu_User();
	
	$feed_id = (int) $this->data->FeedID;
	$feed = JAJobBoardModelJAXMLImport::fcnLoadFeedRow($feed_id);
	
	if (JRequest::getVar("error", "false") == "false") {
		$feed['FMD']->fcnFillRequest();
	} else {
		$feed['FMD']->fcnFillOptions();
	}
	
	?>
        	<br/>
	<fieldset class="adminform">	
		<legend><?php echo JText::_( 'SETUP FEED STRUCT' ); ?></legend>
		<table class="admintable" width="100%" border="1px" style="border-collapse:collapse;  border-color:#CCCCCC" cellspacing="2" cellpadding="4">
		
		<tr>
			<td>
			<?php echo JText::_("PLEASE IDENTIFY THE SEQUENCE ELEMENT, EX. THE ELEMENT WHICH CONATINS THE JOB POST DATA STRUCTURE. <BR/>CLICK ON THE RADIO BUTTON NEXT TO THE OPENING XML TAG, AND THEN CLICK 'SAVE' <BR/>THE IMPORTING TOOL WILL LOOP THROUGH EACH SEQUENCE ELEMENT AS IT IMPORTS THE DATA FROM YOUR FEED."); ?>
			</td>
		</tr>
		<tr>
			<td>
			
			<div style="display:none; position:absolute; background-color:green;" id="v_line">|</div>
			<?php $xmlFeedForm = new buildXMLStruct($this->data->SampleString, $feed['FMD']->seq);?>			
			</td>
		</tr>
	</table>
	</fieldset>
</div>
<div class="clr"></div>

<input type="hidden" name="option" value="com_jajobboard" />
<input type="hidden" name="FeedID" value="<?php echo $this->data->FeedID;?>" />
<input type="hidden" name="task" value="save" />
<input type="hidden" name="tab" value="feeds" />
<input type="hidden" name="view" value="jaxmlimport" />
</form>